{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "dbf43f7d",
   "metadata": {},
   "source": [
    "## Python创建虚拟环境"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a4e4c85c-bc79-459a-ae17-60a903e6ed06",
   "metadata": {
    "vscode": {
     "languageId": "shellscript"
    }
   },
   "outputs": [],
   "source": [
    "conda create -n gitlib  python=3.8\n",
    "activate gitlib"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "72a2c0dc",
   "metadata": {},
   "source": [
    "## 设置阿里云镜像源"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "bfd6e9e8",
   "metadata": {
    "vscode": {
     "languageId": "shellscript"
    }
   },
   "outputs": [],
   "source": [
    "!pip config set global.index-url https://mirrors.aliyun.com/pypi/simple\n",
    "!pip config set install.trusted-host mirrors.aliyun.com"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "6cea006c",
   "metadata": {
    "vscode": {
     "languageId": "shellscript"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Writing to C:\\Users\\Administrator\\AppData\\Roaming\\pip\\pip.ini\n",
      "Writing to C:\\Users\\Administrator\\AppData\\Roaming\\pip\\pip.ini\n"
     ]
    }
   ],
   "source": [
    "## 清华镜像源\n",
    "!pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple\n",
    "!pip config set install.trusted-host pypi.tuna.tsinghua.edu.cn\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "8de05074",
   "metadata": {
    "vscode": {
     "languageId": "shellscript"
    }
   },
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "invalid syntax (29450770.py, line 2)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;36m  Cell \u001b[1;32mIn[12], line 2\u001b[1;36m\u001b[0m\n\u001b[1;33m    python -m pip install --upgrade pip\u001b[0m\n\u001b[1;37m              ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m invalid syntax\n"
     ]
    }
   ],
   "source": [
    "## 更新pip在命令行中运行\n",
    "python -m pip install --upgrade pip"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "e51b3795",
   "metadata": {
    "vscode": {
     "languageId": "shellscript"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple\n",
      "Collecting gitpython\n",
      "  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/e9/bd/cc3a402a6439c15c3d4294333e13042b915bbeab54edc457c723931fed3f/GitPython-3.1.43-py3-none-any.whl (207 kB)\n",
      "Collecting pymongo\n",
      "  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/38/52/a58196a45232e9046c8b13f4fa3d89cca0e462b5c6d28969759226f781ee/pymongo-4.10.1-cp38-cp38-win_amd64.whl (727 kB)\n",
      "     ---------------------------------------- 0.0/727.4 kB ? eta -:--:--\n",
      "     ------------------------------------- 727.4/727.4 kB 29.1 MB/s eta 0:00:00\n",
      "Collecting pandas\n",
      "  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/c3/6c/ea362eef61f05553aaf1a24b3e96b2d0603f5dc71a3bd35688a24ed88843/pandas-2.0.3-cp38-cp38-win_amd64.whl (10.8 MB)\n",
      "     ---------------------------------------- 0.0/10.8 MB ? eta -:--:--\n",
      "     ------------------ --------------------- 5.0/10.8 MB 23.1 MB/s eta 0:00:01\n",
      "     --------------------------------------- 10.8/10.8 MB 25.8 MB/s eta 0:00:00\n",
      "Collecting numpy\n",
      "  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/69/65/0d47953afa0ad569d12de5f65d964321c208492064c38fe3b0b9744f8d44/numpy-1.24.4-cp38-cp38-win_amd64.whl (14.9 MB)\n",
      "     ---------------------------------------- 0.0/14.9 MB ? eta -:--:--\n",
      "     ----------- ---------------------------- 4.2/14.9 MB 28.1 MB/s eta 0:00:01\n",
      "     -------------------------------- ------ 12.3/14.9 MB 32.2 MB/s eta 0:00:01\n",
      "     --------------------------------------- 14.9/14.9 MB 27.5 MB/s eta 0:00:00\n",
      "Collecting gitdb<5,>=4.0.1 (from gitpython)\n",
      "  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/fd/5b/8f0c4a5bb9fd491c277c21eff7ccae71b47d43c4446c9d0c6cff2fe8c2c4/gitdb-4.0.11-py3-none-any.whl (62 kB)\n",
      "Collecting dnspython<3.0.0,>=1.16.0 (from pymongo)\n",
      "  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/87/a1/8c5287991ddb8d3e4662f71356d9656d91ab3a36618c3dd11b280df0d255/dnspython-2.6.1-py3-none-any.whl (307 kB)\n",
      "Requirement already satisfied: python-dateutil>=2.8.2 in e:\\tools\\anaconda3\\envs\\gitlib\\lib\\site-packages (from pandas) (2.9.0)\n",
      "Collecting pytz>=2020.1 (from pandas)\n",
      "  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/11/c3/005fcca25ce078d2cc29fd559379817424e94885510568bc1bc53d7d5846/pytz-2024.2-py2.py3-none-any.whl (508 kB)\n",
      "Collecting tzdata>=2022.1 (from pandas)\n",
      "  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/a6/ab/7e5f53c3b9d14972843a647d8d7a853969a58aecc7559cb3267302c94774/tzdata-2024.2-py2.py3-none-any.whl (346 kB)\n",
      "Collecting smmap<6,>=3.0.1 (from gitdb<5,>=4.0.1->gitpython)\n",
      "  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/a7/a5/10f97f73544edcdef54409f1d839f6049a0d79df68adbc1ceb24d1aaca42/smmap-5.0.1-py3-none-any.whl (24 kB)\n",
      "Requirement already satisfied: six>=1.5 in e:\\tools\\anaconda3\\envs\\gitlib\\lib\\site-packages (from python-dateutil>=2.8.2->pandas) (1.16.0)\n",
      "Installing collected packages: pytz, tzdata, smmap, numpy, dnspython, pymongo, pandas, gitdb, gitpython\n",
      "Successfully installed dnspython-2.6.1 gitdb-4.0.11 gitpython-3.1.43 numpy-1.24.4 pandas-2.0.3 pymongo-4.10.1 pytz-2024.2 smmap-5.0.1 tzdata-2024.2\n"
     ]
    }
   ],
   "source": [
    "!pip install gitpython pymongo pandas numpy"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "e3cf04b0",
   "metadata": {
    "vscode": {
     "languageId": "shellscript"
    }
   },
   "outputs": [],
   "source": [
    "#创建测试目录\n",
    "!mkdir logs\n",
    "!mkdir tests\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "eaccfb83",
   "metadata": {
    "vscode": {
     "languageId": "shellscript"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple\n",
      "Could not fetch URL https://pypi.tuna.tsinghua.edu.cn/simple/python-gitlab/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.tuna.tsinghua.edu.cn', port=443): Max retries exceeded with url: /simple/python-gitlab/ (Caused by SSLError(SSLZeroReturnError(6, 'TLS/SSL connection has been closed (EOF) (_ssl.c:1149)'))) - skipping\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLZeroReturnError(6, 'TLS/SSL connection has been closed (EOF) (_ssl.c:1149)'))': /simple/python-gitlab/\n",
      "WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLZeroReturnError(6, 'TLS/SSL connection has been closed (EOF) (_ssl.c:1149)'))': /simple/python-gitlab/\n",
      "WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLZeroReturnError(6, 'TLS/SSL connection has been closed (EOF) (_ssl.c:1149)'))': /simple/python-gitlab/\n",
      "WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLZeroReturnError(6, 'TLS/SSL connection has been closed (EOF) (_ssl.c:1149)'))': /simple/python-gitlab/\n",
      "WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLZeroReturnError(6, 'TLS/SSL connection has been closed (EOF) (_ssl.c:1149)'))': /simple/python-gitlab/\n",
      "ERROR: Could not find a version that satisfies the requirement python-gitlab (from versions: none)\n",
      "ERROR: No matching distribution found for python-gitlab\n"
     ]
    }
   ],
   "source": [
    "!pip install python-gitlab"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
